package com.iwhalecloud.bss.kite.cucc.service.attr.handler;

import com.iwhalecloud.bss.kite.common.constant.KeyConsts;
import com.iwhalecloud.bss.kite.cucc.service.attr.LocalAttrHelper;
import com.iwhalecloud.bss.kite.listener.handler.attr.annotation.AttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.impl.AbstractAttrLinkageHandler;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import org.springframework.stereotype.Service;
import java.util.Objects;

@Service
@AttrHandler(SalesWayZHZXAttrHandler.class)
public class SalesWayZHZXAttrLinkHandler extends AbstractAttrLinkageHandler<AttrData> {

    @Override
    public void handle(KiteAttr attr, KiteInst inst, AttrData data) {
        String value = attr.getValue();
        if(Objects.isNull(value)){
            return;
        }
        String [] attr_whs = {"210005149","210008313","210008314","210008315","210008316","210008317"};
        String attr_whh = "210005149";
        String [] attr_dxs = {"200001012","200001010", "200001011"};
        String  attr_dxh = "210005148";
        //包含短信 显示短信内容和数据服务费中要求属性
        if(value.contains("100000727")){
            for(String fldName : attr_dxs){
                LocalAttrHelper.showAndNotNull(inst,fldName);
            }
            inst.getAttr(attr_dxh).setShowType(KeyConsts.PROD_ATTR_SHOW_TYPE_H);
        }else {
            for(String fldName : attr_dxs){
                LocalAttrHelper.hideAndNullable(inst,fldName);
            }
            inst.getAttr(attr_dxh).setShowType(KeyConsts.PROD_ATTR_SHOW_TYPE_E);
        }

        if(value.contains("100000756")){
            for(String fldName : attr_whs){
                LocalAttrHelper.showAndNotNull(inst,fldName);
            }
            inst.getAttr(attr_whh).setShowType(KeyConsts.PROD_ATTR_SHOW_TYPE_H);
        }else {
            for(String fldName : attr_whs){
                LocalAttrHelper.hideAndNullable(inst,fldName);
            }
            inst.getAttr(attr_whh).setShowType(KeyConsts.PROD_ATTR_SHOW_TYPE_E);
        }
    }

    @Override
    public void handleStyle(KiteAttr attr, KiteInst inst, AttrData data) {

    }

}
